package com.thermal.thermal_inspection.service.impl;

import com.thermal.thermal_inspection.entity.CaseInfo;
import com.thermal.thermal_inspection.mapper.CaseInfoMapper;
import com.thermal.thermal_inspection.service.CaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CaseInfoServiceImpl implements CaseInfoService {

    @Autowired
    private CaseInfoMapper caseInfoMapper;

    @Override
    public int addQuestion(CaseInfo caseInfo) {
        caseInfoMapper.insertQuestion(caseInfo);
        return caseInfo.getCaseInfoId(); // 返回自增主键
    }

    @Override
    public boolean updateAnswer(int caseInfoId, String answerInfo) {
        return caseInfoMapper.updateAnswer(caseInfoId, answerInfo) > 0;
    }

    @Override
    public List<CaseInfo> getByCaseId(int caseId) {
        return caseInfoMapper.getCaseInfosByCaseId(caseId);
    }
}
